package org.ucas.faker.web.service.Visualization.entity;

import com.alibaba.fastjson.JSONArray;
import org.ucas.faker.web.service.Visualization.entity.component.Basis;
import org.ucas.faker.web.service.Visualization.entity.component.Branch;
import org.ucas.faker.web.service.Visualization.entity.component.Target;

import java.util.ArrayList;
import java.util.List;

public class VisualParam <T> {


    private String graphName = null;
    private String graphType = null;


    /*    private JSONArray basisLabel = null;
        private String basisName = null;*/
    private Basis basis = new Basis();


    /*private JSONArray branchLabel = null;
        private String branchName = null;*/
    private Branch branch = new Branch();

    private List<T>[] dataArray = null;  //泛型T一般为long, double, int
    private List<Double>[] percentageDataArray = null;
    private List<T[]> multiDimensionData = null;
    private List<String> multiDimensionLabel = null;

    private long depotId = 0;

    /*private String targetName = null;
    private String[] multiTargetName = null;*/

    private Target target = new Target();
    private Target[] multiTarget = null;

    private int basisDimension = 0;
    private int targetDimension = 0;

    public VisualParam(){
        this.dataArray = new ArrayList[1];
        this.dataArray[0] = new ArrayList<T>();
        this.basisDimension = 2;
    }

    public List<Double>[] getPercentageDataArray() {
        return percentageDataArray;
    }

    public void setPercentageDataArray(List<Double>[] percentageDataArray) {
        this.percentageDataArray = percentageDataArray;
    }

    public List<T[]> getMultiDimensionData() {
        return multiDimensionData;
    }

    public void setMultiDimensionData(List<T[]> multiDimensionData) {
        this.multiDimensionData = multiDimensionData;
    }

    public List<String> getMultiDimensionLabel() {
        return multiDimensionLabel;
    }

    public void setMultiDimensionLabel(List<String> multiDimensionLabel) {
        this.multiDimensionLabel = multiDimensionLabel;
    }

    public String[] getMultiTargetName() {
        String[] nameArray = new String[this.getMultiTarget().length];
        for (int i=0;i<nameArray.length;i++){
            nameArray[i] = this.getMultiTarget()[i].getName();
        }
        return nameArray;
    }

    public void setMultiTargetName(String[] multiTargetName) {
        if (multiTargetName.length != this.getMultiTarget().length){
            return;
        }
        for (int i=0;i<multiTargetName.length;i++) {
            this.getMultiTarget()[i].setName(multiTargetName[i]);
        }
    }

    public int getBasisDimension() {
        return basisDimension;
    }

    public void setBasisDimension(int basisDimension) {
        this.basisDimension = basisDimension;
    }

    public int getTargetDimension() {
        return targetDimension;
    }

    public void setTargetDimension(int targetDimension) {
        this.targetDimension = targetDimension;
    }

    public String getTargetName() {
        return this.getTarget().getName();
    }

    public void setTargetName(String targetName) {
        this.getTarget().setName(targetName);
    }

    public long getDepotId() {
        return depotId;
    }

    public void setDepotId(long depotId) {
        this.depotId = depotId;
    }

    public String getGraphName() {
        return graphName;
    }

    public void setGraphName(String graphName) {
        this.graphName = graphName;
    }

    public String getGraphType() {
        return graphType;
    }

    public void setGraphType(String graphType) {
        this.graphType = graphType;
    }

    public JSONArray getBasisLabel() {
        return this.getBasis().getLabel();
    }

    public void setBasisLabel(JSONArray basisLabel) {
        this.getBasis().setLabel(basisLabel);
    }

    public String getBasisName() {
        return this.getBasis().getName();
    }

    public void setBasisName(String basisName) {
        this.getBasis().setName(basisName);
    }

    public String getBasisUnit(){
        return this.getBasis().getUnit();
    }

    public void setBasisUnit(String unit){
        this.getBasis().setUnit(unit);
    }

    public JSONArray getBranchLabel() {
        return this.getBranch().getLabel();
    }

    public void setBranchLabel(JSONArray branchLabel) {
        if (branchLabel!=null){
            this.basisDimension = 3;
        }
        this.getBranch().setLabel(branchLabel);
    }

    public String getBranchName() {
        return this.getBranch().getName();
    }

    public void setBranchName(String branchName) {
        if (branchName!=null){
            this.basisDimension = 3;
        }
        this.getBranch().setName(branchName);
    }

    public String getBranchUnit(){
        return this.getBranch().getUnit();
    }

    public void setBranchUnit(String unit){
        this.getBranch().setUnit(unit);
    }

    public String getTargetUnit(){
        return this.getTarget().getUnit();
    }

    public void setTargetUnit(String unit){
        this.getTarget().setUnit(unit);
    }

    public List<T>[] getDataArray() {
        return dataArray;
    }

    public List<T> getData(int i){
        return this.dataArray[i];
    }

    public List<T> getData(){
        return this.dataArray[0];
    }

    public void setDataArray(List<T>[] dataArray) {
        this.dataArray = dataArray;
    }

    public void setDataList(List<T> dataList){
        this.dataArray = new ArrayList[1];
        this.dataArray[0] = dataList;
    }


    public Basis getBasis() {
        return basis;
    }

    public void setBasis(Basis basis) {
        this.basis = basis;
    }

    public Target getTarget() {
        return target;
    }

    public void setTarget(Target target) {
        this.target = target;
    }

    public Target[] getMultiTarget() {
        return multiTarget;
    }

    public void setMultiTarget(Target[] multiTarget) {
        this.multiTarget = multiTarget;
    }


    public Branch getBranch() {
        return branch;
    }

    public void setBranch(Branch branch) {
        this.branch = branch;
    }
}
